#{extends 'CRUD/layout.html' /}
#{set title:messages.get('patient.add') /}
<script type="text/javascript">
var date;
$(document).ready(function() {
	date = $('#object_birthday').val();
	var datepicker = '#object_birthday';
	$.datepicker.setDefaults($.extend({
		minDate: new Date(1900,0,1),
		maxDate: new Date(),
		yearRange: '1900:+00',
		changeMonth: true,
		changeYear: true},
		$.datepicker.regional['']));
	$(datepicker).datepicker();
	%{
		currentLanguage = play.i18n.Lang.get();
	}%
	$(datepicker).datepicker('option', $.datepicker.regional['&{currentLanguage}'.lenght == 0 ? 'en' : '&{currentLanguage}']);
	$(datepicker).datepicker('option', 'dateFormat', 'dd-mm-yy');
	$('#object_birthday').val(date);
});
</script>

<div id="crudBlank" class="${type.name}">

    <h2 id="crudBlankTitle">&{'patient.add'}</h2>

    <div class="objectForm">
    #{form action:@Patients.savePatientWithCard(), enctype:'multipart/form-data'}
        #{crud.form fields:['lastName', 'firstName', 'middleName', 'gender', 'birthday', 'country', 'region', 'district', 'city', 'street', 'house', 'flat']}
        	#{crud.custom 'gender'}
        	   <label for="${gender}">&{'gender'}</label>
        	   #{select 'object.gender', id:'object_gender', value:object.gender}
					#{option 'MALE'}&{'gender.male'}#{/option}
					#{option 'FEMALE'}&{'gender.female'}#{/option}
				#{/select}
        	#{/crud.custom}
        	
        #{/crud.form}
        
        <p class="crudButtons">
            <input type="submit" name="_save" value="&{'crud.save', type.modelName}" />
            <input type="submit" name="_saveAndContinue" value="&{'crud.saveAndContinue', type.modelName}" />
            <input type="submit" name="_saveAndAddAnother" value="&{'crud.saveAndAddAnother', type.modelName}" />
        </p>
    #{/form}
    </div>

</div>